﻿Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.General
Imports DoAnQuanLyBanHang1065043_1065007.DoAnQuanLyBanHang.DAO
Imports DevComponents.DotNetBar

Public Class frmTimKiemKhachHang
    Private m_KhachHangCtrl As New KhachHangCtrl()
    Public Sub New()
        InitializeComponent()
        DataService.OpenConnection()
    End Sub
    Private Sub frmTimKiemKhachHang_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        m_KhachHangCtrl.HienThi(DGVKhachHang, BindingNavigatorKhachHang)
    End Sub

#Region "Tìm kiếm khách hàng"
    Private Sub btnSearch_KeyDown(sender As Object, e As KeyEventArgs)
        If e.KeyCode = Keys.Enter Then
            TimKiemKhachHang()
        End If
    End Sub

    Private Sub TimKiemKhachHang()
        Try
            If cbMaKH.Checked = True Then
                m_KhachHangCtrl.TimKiemTheoMa(txtTimKiem.Text)
            Else
                m_KhachHangCtrl.TimKiemTheoTen(txtTimKiem.Text)

            End If
        Catch
            MessageBoxEx.Show("Không thể tìm thấy Giá trị cần tìm!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.[Error])
        End Try
    End Sub

    Private Sub btnTimKiem_Click(sender As System.Object, e As System.EventArgs) Handles btnTimKiem.Click
        If txtTimKiem.Text = "" Then
            MessageBoxEx.Show("Giá trị tìm rỗng!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.[Error])
        Else
            TimKiemKhachHang()
        End If
    End Sub
#End Region

    Private Sub bindingNavigatorCloseItem_Click(sender As System.Object, e As System.EventArgs) Handles bindingNavigatorCloseItem.Click
        Me.Close()
    End Sub

    Private Sub btnHuy_Click(sender As System.Object, e As System.EventArgs) Handles btnHuy.Click
        Me.Close()
    End Sub
End Class